home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!pipeline!news
- From: gordo@pipeline.com (Gordo Krefting)
- Newsgroups: comp.lang.c
- Subject: Re: Character string
- Date: Thu, 11 Apr 1996 17:10:51 GMT
- Organization: The Pipeline
- Message-ID: <4kj415$3cb@news.nyc.pipeline.com>
- References: <4kil74$8i7@Tandem1.opennet.net.au>
- NNTP-Posting-Host: pipe12.nyc.pipeline.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- george@opennet.net.au (Kenneth H Smith) wrote:
-
- >How do I do a similar statement in C to the Pascal code:
-
- >If Ch IN ['a','A'] THEN
-
- >I want to execute a piece of code when a particular character is entered
- >from the keyboard.
-
- >I know I can use if (ch=='a') && (ch=='A') but was looking for something
- >a little more ellegant.
-
- >Thanks,
-
- >Ken Smith.
-
- Well, you should probably use:
- if ((ch=='a') || (ch=='A'))
- instead!
-
-
- You might also want to try:
- if (strchr("aA", ch))
-
- be sure to #include <string.h> to get access to the strchr function
-
- hth
- gordo
-
-
-
-
-